package com.magnificent.atlantis.client.data.alert;

import com.magnificent.commons.utils.DateUtils;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Date;

/**
 * User: Babanin
 * Date: 02.02.2009
 * Time: 1:13:08
 */
@XmlRootElement(name = "alert")
public abstract class AbstractAlert {

    private Date date;
    private String title;
    private String message;
    private Date generationDate;
    private boolean read;

    public AbstractAlert() {
        read = false;
        generationDate = new Date();
    }

    public AbstractAlert(String title, String message, Date date) {
        read = false;
        generationDate = new Date();

        this.title = title;
        this.message = message;
        this.date = date;
    }

    public boolean isImportant() {
        return DateUtils.isSameDay(new Date(), getDate());
    }

    @XmlAttribute()
    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    @XmlElement()
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    @XmlAttribute()
    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    @XmlAttribute()
    public Date getGenerationDate() {
        return generationDate;
    }

    public void setGenerationDate(Date generationDate) {
        this.generationDate = generationDate;
    }

    @XmlAttribute()
    public boolean isRead() {
        return read;
    }

    public void setRead(boolean read) {
        this.read = read;
    }

    public boolean isAutomatic() {
        return this instanceof AutomaticAlert;
    }
}
